package com.google.gwt.sample.dynatablerf.client.presenters;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.sample.dynatablerf.shared.GrifoRequestFactory;
import com.google.gwt.user.client.ui.TabLayoutPanel;
import com.google.web.bindery.requestfactory.shared.RequestContext;

public abstract class AbstractHasRequestPresenter<T extends RequestContext>
		extends AbstractTabPresenter {

	private GrifoRequestFactory grifoRequestFactory;

	public AbstractHasRequestPresenter(EventBus eventBus,
			GrifoRequestFactory grifoRequestFactory) {
		super(eventBus);
		this.grifoRequestFactory = grifoRequestFactory;
		grifoRequestFactory.projetoRequest();
	}

	protected abstract void fetch();

	protected GrifoRequestFactory getRequestFactory() {
		return grifoRequestFactory;
	}

	protected abstract T getRequestContext();

	@Override
	public void go(TabLayoutPanel tabLayoutPanel) {
		super.go(tabLayoutPanel);
		fetch();
	}

}
